﻿#Requires AutoHotkey v2.0

SaveToClipBoard()

SaveToClipBoard() {

  hScreenDC := DllCall('GetDC', 'ptr', 0)

  hMemDC := DllCall("CreateCompatibleDC", "Ptr", 0)

  hBitmap := DllCall("CreateCompatibleBitmap", "ptr", hScreenDC, "int", A_ScreenWidth, "int", A_ScreenHeight)

  hOldBitmap := DllCall("SelectObject", "Ptr",hMemDC, "Ptr",hBitmap)

  if DllCall("BitBlt", "Ptr", hMemDC, "int", 0, "int", 0, "int", A_ScreenWidth, "int", A_ScreenHeight
    , "Ptr", hScreenDC, "int", 0, "int", 0, "uint", 0xCC0020)
    MsgBox 'ok'

  hOldBitmap := DllCall("SelectObject", "Ptr",hMemDC, "Ptr",hOldBitmap)

  DllCall('user32.dll\ReleaseDC', 'int', 0, 'uint', hMemDC)
  DllCall('DeleteDC','uint', hScreenDC)

  DllCall("OpenClipboard", "Ptr", 0)
  DllCall("EmptyClipboard")
  DllCall("SetClipboardData", "uint", 2, "Ptr", hBitmap)
  DllCall("CloseClipboard")

  DllCall("DeleteObject", "Ptr", hBitmap)
}